package com.shenke.ihuserservice.controller.inner;

import com.shenke.ihmodel.entity.User;
import com.shenke.ihserviceclient.service.UserFeignClient;
import com.shenke.ihuserservice.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

/**
 * 该服务仅供内部调用，禁止外部访问
 */
@RestController
@RequestMapping("/inner")
public class UserInnerController implements UserFeignClient {

    @Resource
    private UserService userService;

    /**
     * 根据 id 获取用户信息
     *
     * @param userId
     * @return
     */
    @Override
    @GetMapping("/get/id")
    public User getById(@RequestParam("userId") long userId) {
        return userService.getById(userId);
    }

    /**
     * 根据 id 获取用户列表
     *
     * @param IdList
     */
    @Override
    @GetMapping("/list/ids")
    public List<User> listByIds(@RequestParam("IdList") Collection<Long> IdList) {
        return userService.listByIds(IdList);
    }

    /**
     * 获取匹配用户列表
     *
     * @param updateUser
     * @return
     */
    @Override
    @GetMapping("/update/")
    public boolean updateById(@RequestBody User updateUser) {
        return userService.updateById(updateUser);
    }
}
